import * as React from "react";

export default class Welcome extends React.Component{
    constructor (props) {
        super(props);
        this.state = {
            date : new Date()
        };
        this.timeId = null;
    }
    componentDidMount() {
        this.timeId = setInterval(() => {
            this.tick();
        }, 1000)
    }

    componentWillUnmount() {
        clearInterval(this.timeId);
    }

    tick () {
        this.setState({
            date: new Date()
        })
    }

    render() {
        return <h2>hE {this.props.name} {this.state.date.toLocaleString()}</h2>
    }
}